'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    // 添加新字段
    await queryInterface.addColumn('crm_customers', 'rating', {
      type: Sequelize.INTEGER,
      defaultValue: 0,
      after: 'created_by'
    });

    await queryInterface.addColumn('crm_customers', 'next_follow_up', {
      type: Sequelize.DATE,
      allowNull: true,
      after: 'rating'
    });

    await queryInterface.addColumn('crm_customers', 'deal_size', {
      type: Sequelize.DECIMAL(10, 2),
      allowNull: true,
      defaultValue: 0,
      after: 'next_follow_up'
    });

    await queryInterface.addColumn('crm_customers', 'last_contact_date', {
      type: Sequelize.DATE,
      allowNull: true,
      after: 'deal_size'
    });
  },

  down: async (queryInterface, Sequelize) => {
    // 回滚操作 - 删除字段
    await queryInterface.removeColumn('crm_customers', 'rating');
    await queryInterface.removeColumn('crm_customers', 'next_follow_up');
    await queryInterface.removeColumn('crm_customers', 'deal_size');
    await queryInterface.removeColumn('crm_customers', 'last_contact_date');
  }
}; 